package cn.lovecyy.mockjson.core.gen;

import cn.lovecyy.mockjson.core.gen.company.CompanyInfo;
import com.apifan.common.random.entity.EconomicCategory;
import com.apifan.common.random.source.AreaSource;
import com.apifan.common.random.source.DateTimeSource;
import com.apifan.common.random.source.OtherSource;
import com.apifan.common.random.source.PersonInfoSource;

import java.time.LocalDate;

/**
 * CommonRandomUtil
 *
 * @author Yakir
 */
public class CommonRandomUtil {

	public static void main(String[] args) {
		// 生成1个随机中国大陆详细地址
		AreaSource instance = AreaSource.getInstance();
		String addr = instance.randomAddress();
		EconomicCategory economicCategory = OtherSource.getInstance().randomEconomicCategory();
		System.out.println(economicCategory);
		System.out.println(addr);
		System.out.println(randCompanyInfo());
	}

	public static CompanyInfo randCompanyInfo() {
		CompanyInfo companyInfo = new CompanyInfo();
		companyInfo.setCompanyName(OtherSource.getInstance().randomCompanyName(""));
		companyInfo.setCreditNo(OtherSource.getInstance().randomSocialCreditCode());
		companyInfo.setCompanyAddress(AreaSource.getInstance().randomAddress());
		companyInfo.setLegalPerson(PersonInfoSource.getInstance().randomChineseName());
		String dd = DateTimeSource.getInstance().randomPastDate(LocalDate.of(2025, 1, 2), 3650, "yyyy-MM-dd");
		companyInfo.setEstablishDate(dd);
		return companyInfo;
	}

}
